﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;

namespace OnlineBusTicket.Phucnh
{
    public partial class UpdatePersonInfor : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                //int UserId = Int32.Parse(Session["UserId"].ToString());// neu ko can dung userid
                string userName = HttpContext.Current.User.Identity.Name;
                lblUserName.Text = userName;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string userName = HttpContext.Current.User.Identity.Name;
            SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            con.Open();
            SqlCommand cmd = new SqlCommand("UPDATE Member SET [FullName]='" + txtFullName.Text + "',[Gender]='" + Convert.ToString(ddlGender.SelectedValue) + "',[Age]=" + Convert.ToInt32(txtAge.Text) + ",[Address]='" + txtAddress.Text + "',[Phone]='" + txtPhone.Text + "' WHERE [UserName]='" + userName + "'", con);
            cmd.ExecuteNonQuery();
            con.Close();
            Response.Redirect("PersonalInformation.aspx");
        }
    }
}